﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTO;
using Data;

namespace Bussiness {
    public class KhachHangService {
        /// <summary>
        /// lấy toàn bộ bảng khách hàng
        /// </summary>
        /// <returns></returns>
        public List<KhachHangDTO> GetKhachHangList() {
            KhachHangRepository repository = new KhachHangRepository();
            return repository.SelectAllKhachHangs();
        }

        public int GetDebt(int khachHangID) {
            KhachHangRepository res = new KhachHangRepository();
            return res.GetDebt(khachHangID);
        }

        public bool UpdateKhachHang(KhachHangDTO value) {
            KhachHangRepository res = new KhachHangRepository();
            return res.UpdateKhachHang(value);
        }

        public string CreateMaKhachHang() {
            KhachHangRepository res = new KhachHangRepository();
            return res.CreateMaKhachHang();
        }

        /// <summary>
        /// themmoi 1 khach hang
        /// </summary>
        /// <param name="khachHang"></param>
        /// <returns></returns>
        public bool InsertNewKhachHang(KhachHangDTO khachHang) {
            KhachHangRepository res = new KhachHangRepository();
            return res.InsertNewKhachHang(khachHang);
        }

        /// <summary>
        /// tim kiem thong tin khach hang
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public List<KhachHangDTO> SearchKhachHang(string value) {
            KhachHangRepository res = new KhachHangRepository();
            return res.SearchKhachHang(value);
        }

        public List<KhachHangDTO> SearchKhachHang(string tenKhachHang, string maKhachHang, string diaChi, string soDienThoai, string email) {
            KhachHangRepository res = new KhachHangRepository();
            return res.SearchKhachHang(tenKhachHang, maKhachHang, diaChi, soDienThoai, email);
        }

        public bool UpdateKhachHang(List<KhachHangDTO> khachHangList) {
            KhachHangRepository res = new KhachHangRepository();
            return res.UpdateKhachHang(khachHangList);
        }
    }
}
